package com.office.supplies.mapper;

import com.office.supplies.pojo.Employee;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Author admin
 * @Description TODO
 * @Date 2023/12/09/19:57
 */
@Mapper
public interface EmployeeMapper {

    /**
     * 新增员工
     *
     * @param employee Employee
     */
    @Insert("insert into employee (name, password, user_type) value (#{name}, #{password}, #{userType})")
    void insert(Employee employee);

    /**
     * 条件查询员工
     *
     * @param employee Employee
     * @return List<Employee>
     */
    List<Employee> selectAllEmployee(Employee employee);

    /**
     * 根据id查询员工
     *
     * @param id Long
     * @return Employee
     */
    @Select("select * from employee where id = #{id}")
    Employee selectEmployeeById(Long id);

    /**
     * 员工登录
     *
     * @param employee Employee
     * @return Employee
     */
    @Select("select * from employee where name = #{name} and password = #{password} and user_type = #{userType}")
    Employee selectEmployee(Employee employee);

    /**
     *修改员工
     *
     * @param employee Employee
     */
    void updateEmployee(Employee employee);

    @Delete("delete from employee where id = #{id}")
    void deleteEmployeeById(Long id);

}
